home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10732 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  46 lines

  1. Path: inforamp.net!ts6-06
  2. From: rmorin@inforamp.net (Randy Charles Morin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Initializing an Array of Strings
  5. Date: Sat, 09 Mar 96 20:25:08 GMT
  6. Organization: MiddleWorld SoftWare
  7. Message-ID: <4hspfg$rsm@sam.inforamp.net>
  8. References: <31409559.1FC6@enigma.vcr.esltd.com>
  9. NNTP-Posting-Host: ts6-06.tor.inforamp.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <31409559.1FC6@enigma.vcr.esltd.com>,
  13.    Eric Kolotyluk <eric@enigma.vcr.esltd.com> wrote:
  14. >Please reply to eric@enigma.vcr.esltd.com
  15. >
  16. >        char*        errorName[];
  17. >Is there something basically wrong with what I'm trying to do?
  18. >I just don't see what the problem is with the definition of errorName.
  19. >Also, is there a way to initialize something with an array of strings?
  20.  
  21. In most cases, you cannot initial an array without telling the compiling what 
  22. the size.  Some people use the notation
  23.  
  24.     char erroName[]={"Randy"};
  25.  
  26. ..but the length is implicitly implied.
  27. I'm assuming that you want an array of strings.
  28. Thus you should use...
  29.     
  30.     char ** errorName;
  31.  
  32. ..but the code would be cumbersome.
  33. The best thing to do is use a container class and an C++ string class.
  34.  
  35. MFC has a great container class called CArrayString (or something like that) 
  36. that is an array of CString's.  OWL has a class called TArrayAsVector that can 
  37. be extended (very very easily) to be an array of String's.  CString and String 
  38. are encapsulation of a character strings.  They are very powerful.
  39.  
  40. If you don't have access to a container class and a C++ string class, then I 
  41. suggest you give yourself access to one, by finding one or writing one.  
  42. They'll save you endless amounts of time.  I need to parse a CString (MFC) and 
  43. simply extended CString by adding more << operators.  Saved me hours of time.
  44.  
  45. Agrivar
  46.